home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1997 #1
/
Amiga Plus CD - 1997 - No. 01.iso
/
pd
/
sonstiges
/
spontimag10
/
owindow.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-14
|
3KB
|
156 lines
/****** OWindow.cpp ***********************************************
*
* PROGRAM
* OWindow
*
* CONTENTS
* C++-class for creating a simple window, and parsing messages.
*
* AUTHOR
* Georg Pfundt
*
* COPYRIGHT
* © by Georg Pfundt 14-OCT-1996
*
* LANGUAGE
* ANSI-C
*
* TRANSLATOR
* SAS-C V6.55
*
* HISTORY
* 1.0, GeP, 14-OCT-1996, first version
* <Version, Autor, Datum, Bemerkung>
*
* SUPPORT
* None.
*
* IMPORTS
* None.
*
* BUGS
* None known.
*
* ADDRESS
* Georg Pfundt, Im Oberviertel 18, 76229 Karlsruhe, Germany
*
* PHONE
* +49 (0)721/481591
* E-Mail: gp@ict.fhg.de
*
* UPDATE
*
********************************************************************
* TABSIZE=2
*/
#include "OWindow.h"
// Define constructor
OWindow::OWindow(const char *name,const ULONG width, const ULONG height,
const ULONG xofs, const ULONG yofs)
{
// Open a window with taglist
this->window = OpenWindowTags(NULL,
WA_Width,width,
WA_Height,height,
WA_Left,xofs,
WA_Top,yofs,
WA_MinWidth, 100L,
WA_MinHeight, 80L,
WA_MaxWidth, -1L,
WA_MaxHeight, -1L,
WA_Title,(ULONG)name,
WA_Flags, WFLG_SMART_REFRESH | WFLG_DRAGBAR | WFLG_CLOSEGADGET |
WFLG_DEPTHGADGET,
WA_IDCMP, IDCMP_CLOSEWINDOW,
WA_AutoAdjust,TRUE,
TAG_END);
// Set Rastport
this->RP=NULL;
if (this->window)
RP=this->window->RPort;
}
// Destructor
OWindow::~OWindow(void)
{
// if there are any open messages reply it!
struct IntuiMessage *imsg;
while ((imsg = (struct IntuiMessage*)GetMsg(this->window->UserPort)) != NULL)
ReplyMsg((struct Message*)imsg);
if (this->window)
CloseWindow(this->window);
this->window = NULL;
}
// Get and parse Message
// This function parses known messages or returns OW_None
OWindow::OW_Event
OWindow::ParseMessage(struct IntuiMessage *imsg)
{
OW_Event result;
// Parse Message Class
switch (imsg->Class)
{
case IDCMP_CLOSEWINDOW:
result = OW_Close;
break;
default:
result = OW_None;
}
return result;
}
// Check for a new message, parse it, reply it and return
OWindow::OW_Event
OWindow::CheckMessage(void)
{
struct IntuiMessage *imsg;
OW_Event result=OW_None;
if ((imsg = (struct IntuiMessage*)GetMsg(this->window->UserPort)) != NULL)
{
result = ParseMessage(imsg);
ReplyMsg((struct Message*)imsg);
}
return result;
}
// Wait for a new message.
OWindow::OW_Event
OWindow::WaitMessage(void)
{
struct IntuiMessage *imsg;
OW_Event result=OW_None;
if (WaitPort(this->window->UserPort) != NULL)
{
if ((imsg = (struct IntuiMessage*)GetMsg(this->window->UserPort)) != NULL)
{
result = ParseMessage(imsg);
ReplyMsg((struct Message*)imsg);
}
}
return result;
}